#!/usr/bin/python
#Filename: back_ver3.py

import os
import time

source = ['/nothing/common', '/root/AD']

target_dir = '/tmp/'

today = target_dir + time.strftime('%Y%m%d')
now = time.strftime('%H%M%S');

print "today %s" % today
print "now %s" % now

comment = raw_input("Enter a comment --> ");

print "[comment '%s']" % comment
print "comment.replace %s" % comment.replace(' ', '_')

if len(comment) == 0:
    target = today + os.sep + now + '.zip'
else:
    target = today + os.sep + now + '_' + comment.replace(' ', '_') + '.zip'

print "target ", target

if not os.path.exists(today):
    os.mkdir(today)
    print 'Successfully created directory ', today

zip_command = "zip -qr %s %s" % (target, ' '.join(source))

if os.system(zip_command) == 0:
    print 'Successfully backup to ', target
else:
    print 'Backup failed'

